package com.wk.springframework.config;

import java.util.HashMap;
import java.util.Map;

public class BeanFactory {

    private Map<String, BeanDefinition> beanDefinitionMap = new HashMap<>(4);

    public void registryBeanDefinition(String beanName, BeanDefinition beanDefinition) {
        beanDefinitionMap.put(beanName, beanDefinition);
    }

    public BeanDefinition getBeanDefinition(String beanName) {
        return beanDefinitionMap.get(beanName);
    }

    public <T> T getBean(BeanDefinition beanDefinition) {
        return (T) beanDefinition.getBean();
    }

}
